package com.example.liliang.activitydemo;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

    private Button button;
    private TextView textView;
    private ButtonListerner buttonListerner;
    private int count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.textView);
        textView.setText("你好啊啊啊 jj");
        textView.setTextColor(Color.RED);
        button = findViewById(R.id.btn);
        buttonListerner = new ButtonListerner();
        button.setOnClickListener(buttonListerner);
    }

    /**
     * 点击事件监听器
     */
    class ButtonListerner implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            count++;
            textView.setText("点击了" + count + "次");
        }
    }

}
